Public Class frmATTENDANCE
    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub AttendanceAdd(ByVal Type As Integer)
        Dim arName As New ArrayList
        arName.Add("@CARD_NUMBER")
        arName.Add("@CARD_NAME")
        arName.Add("@TYPE")
        Dim arVal As New ArrayList
        arVal.Add(txtCardNumber.Text)
        arVal.Add(txtCardName.Text)
        arVal.Add(Type)
        BLL.Object_Update_NonResult("", arName, arVal)

        txtCardNumber.Text = ""
        txtCardName.Text = ""
        Search()
    End Sub
    Private Sub btnCheckIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckIn.Click
        AttendanceAdd(1)
    End Sub

    Private Sub txtCardNumber_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtCardNumber.KeyDown
        If e.KeyCode = Keys.Enter Then
            Dim dt As DataTable = BLL.ObjectGetAll("EMPLOYEE_LOADALL")
            Dim dv As New DataView(dt)
            dv.RowFilter = "EMP_CARD='" + txtCardNumber.Text + "'"
            If dv.Count >= 1 Then
                txtCardName.Text = dv(0).Item("EMP_NAME").ToString
            End If
        End If
    End Sub
    Private Sub Search()
        Dim arName As New ArrayList
        arName.Add("@DATE")
        Dim arVal As New ArrayList
        arVal.Add(PublicVariable.SystemDate)
        GridAttendance.DataSource = BLL.ObjectGetBy("ATTENDANCE_LOAD", arName, arVal)
    End Sub

    Private Sub btnCheckOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckOut.Click
        AttendanceAdd(2)
    End Sub

    Private Sub frmATTENDANCE_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Try
            GC.Collect()
            Me.Dispose()
        Catch ex As Exception

        End Try
    End Sub

    Private Sub frmATTENDANCE_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        PublicFunction.NewFormLoad(Me)
        Search()
    End Sub
End Class